package com.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.crm.entity.Permission;
import com.crm.repository.PermissionRepository;
import com.crm.service.PermissionService;
@Service
public class PermissionServiceImpl implements PermissionService {
	@Autowired
	private PermissionRepository repository;

	@Override
	public List<Permission> getPermissionByRoleId(Integer id) {
		
		return repository.getPermissionByRoleId(id);
	}

	@Override
	public String manageRole_Permission(Integer rid, String pids) {
	    repository.delRole_Permission(rid);//先删除所有权限
	    String [] pidss=pids.split(",");
	    for(int i=0;i<pidss.length;i++) {
	    	repository.addRole_Permission(rid, Integer.parseInt(pidss[i]));
	    }
		return "提交成功";
	}

}
